<?php
	namespace Index\Controller;
	use Think\Controller;
/**
 * 注册控制器
 */
	class RegController extends CommonController {
	    public function index(){
	    	if (isset($_SESSION['uid'])) {
				$this->success('你已登录', U('index/user/index'));exit;
			}
	    	$question=D('vercode')->getOne();
	    	$this->assign('question',$question);
	    	//注册说明
	    	$this->assign('title',"注册");
	       $this->display();
	    }

	    public function add()
	    {


	    	

	    	D('vercode')->checkCode(I('post.vercode'));
	    	if (I('post.pass')!=I('post.repass')) {
	    		Reajax(1,"两次密码不一样");
	    	}
			D('user')->checkEmail(I('post.email'));

			D('user')->checkNickname(I('post.nickname'));

			$data=I('post.');
			$data['create_time']=time();
			$data['password']=md5($data['pass']);

			

			$arr=["/Public/Index/images/11424.gif","/Public/Index/images/26880.gif","/Public/Index/images/784224.jpg"];	

			$data['face']=$arr[mt_rand(0,2)];

			if (M('user')->add($data)) {
				Reajax(0,"注册成功");
			}else{
				Reajax(1,"注册失败，请重新注册");
			}
			

	    }







	} 
?>